<?php if (empty($this->data)) : ?>
    <div class="fail-flash">No record found.</div>
<? else : // ถ้ามีข้อมูล ?>
<?php $paginator->options(array('update' => 'divPopUpProductPaginate', 'indicator' => 'indicator')); ?>
<?php echo $this->element('dataCaptionLimit', array('update' => 'divPopUpProductPaginate', 'action' => 'popup_paginate')); ?>
<?php $cur = $paginator->counter(array('format' => '%start%')); ?>
        <table class="data">
            <thead>
                <tr>
                    <th>No</th>
                    <th>&nbsp;</th>
                    <th width="100px"><?php echo $paginator->sort("Current Stock", 'CustProductSite.current_stock'); ?></th>
                    <th class="action"></th>
                </tr>
            </thead>
            <tbody>
        <?php foreach ($this->data as $i => $data): ?>
            <tr class="<?php echo (($i + 1) % 2 == 0) ? 'even-cell' : 'odd-cell'; ?>">
                <td class="center"><?php echo $i + 1; ?></td>
                <td style="min-width: 600px;">
                    <div class="inline-block bold" style="width: 33%;"><?php echo $html->link($data['CustProductSite']['stock_code'], 'view/' . $data['CustProductSite']['id'], array('target' => '_blank')); ?></div>
                    <div class="inline-block" style="width: 33%;"><?php echo $data['CustProductSite']['dispatch_from'] == ITS_PREFIX ? $data['Product']['part_no'] : $data['Product']['supplier_part_no']; ?></div>
                    <div class="inline-block" style="width: 33%;"><?php echo isset($data['Product']['Category']['name']) ? $data['Product']['Category']['name'] : '-'; ?></div>
                    <br />
                    <div class="inline-block" style="width: 33%;"><?php echo $data['Product']['Brand']['name']; ?></div>
                    <div class="inline-block" style="width: 33%;"><?php echo $data['Product']['model']; ?></div>
                    <div class="inline-block" style="width: 33%;"><?php echo isset($data['ProductSerial'][0]) && isset($data['ProductSerial'][0]['CustLocation']['name'])? $data['ProductSerial'][0]['CustLocation']['name'] : '-'; ?></div>
                    <div><?php echo!empty($data['CustProductSite']['text']) ? $data['CustProductSite']['text'] : $data['Product']['text']; ?></div>
                </td>
                <td class="text-right">&nbsp;<?php echo $data['CustProductSite']['current_stock']; ?></td>
                <td><?php echo $html->link($html->image('icon/edit.png'), '#', array('onclick' => "popup_click('{$data['CustProductSite']['stock_code']}')", 'title' => 'Select'), null, false); ?></td>
            <?php endforeach; ?>
    </tbody>
</table>
<?php echo $this->element('paging'); ?>
<? endif; ?>
<?php //debug($this->data); ?>